package com.ems.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.ems.dto.DataBean;
import com.ems.service.TestServer;

@RestController
public class TestController {

	@Autowired
	private TestServer testServer;

	@RequestMapping("/testInstert")
	public Object testInstert() {
		try {
			testServer.add();
			return "success";
		} catch (Exception e) {
			return e;
		}
	}

	@RequestMapping("/instert")
	public Object instert(String data) {
		try {
			DataBean databeean = JSON.parseObject(data, DataBean.class);
			testServer.addDate(databeean);
			return "success";
		} catch (Exception e) {
			e.printStackTrace();
			return e;
		}
	}

	@RequestMapping("/query")
	public Object query() {
		try {
			return testServer.query();
		} catch (Exception e) {
			e.printStackTrace();
			return e;
		}
	}
}
